<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('供应商信息列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>[[#{supplier.name}]]：</label>
                                <input type="text" name="supplierName"/>
                            </li>
                            <li>
                                <label>[[#{supplier.code}]]：</label>
                                <input type="text" name="supplierCode"/>
                            </li>
                            <li>
                                <label>[[#{region}]]：</label>
                                <input type="text" name="countryRegion" th:placeholder="#{region}"/>
                            </li>
                            <li>
                                <label>[[#{companyName}]]：</label>
                                <input type="text" name="companyName"/>
                            </li>
                            <li>
                                <label>[[#{status}]]：</label>
                                <select name="status" th:with="type=${@dict.getType('sys_normal_disable')}">
                                    <option value="">[[#{all}]]</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>[[#{taxScale}]]：</label>
                                <select name="taxScale" th:with="type=${@dict.getType('jt_tax_scale')}"><!-- 纳税规模 -->
                                    <option value="">[[#{all}]]</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>[[#{paymentMethod}]]：</label>
                                <select name="paymentMethod" th:with="type=${@dict.getType('jt_supplier_payment_method')}">
                                    <option value="">[[#{all}]]</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>[[#{createTime}]]：</label>
                                <input type="text" class="time-input" id="beginCreateTime" th:placeholder="#{beginTime}" name="params[beginCreateTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endCreateTime" th:placeholder="#{endTime}" name="params[endCreateTime]" />
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;[[#{search}]]</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;[[#{reset}]]</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="business:supplier:add">
                    <i class="fa fa-plus"></i> [[#{add}]]
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="business:supplier:edit">
                    <i class="fa fa-edit"></i> [[#{edit}]]
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="business:supplier:remove">
                    <i class="fa fa-remove"></i> [[#{delete}]]
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="business:supplier:export">
                    <i class="fa fa-download"></i> [[#{export}]]
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('business:supplier:edit')}]];
        var removeFlag = [[${@permission.hasPermi('business:supplier:remove')}]];
        var prefix = ctx + "business/supplier";

        var taxScaleDatas = [[${@dict.getType('jt_tax_scale')}]];
        var paymentMethodDatas = [[${@dict.getType('jt_supplier_payment_method')}]];
        var statusDatas = [[${@dict.getType('sys_normal_disable')}]];

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: i18n('supplier.info'),
                columns: [{
                    checkbox: true
                },
                {
                    field: 'supplierId',
                    title: '供应商id',
                    visible: false
                },
                {
                    field: 'supplierName',
                    title: i18n('supplier.name')
                },
                {
                    field: 'supplierCode',
                    title: i18n('supplier.code')
                },
                {
                    field: 'countryRegion',
                    title: i18n('region')
                },
                {
                    field: 'currency',
                    title: i18n('currency')
                },
                {
                    field: 'countryCode',
                    title: i18n('countryCode')
                },
                {
                    field: 'phoneNumber',
                    title: i18n('phoneNumber')
                },
                {
                    field: 'contact',
                    title: i18n('contact')
                },
                {
                    field: 'address',
                    title: i18n('address')
                },
                {
                    field: 'companyName',
                    title: i18n('address')
                },
                {
                    field: 'companyTaxNo',
                    title: i18n('taxNo')
                },
                {
                    field: 'taxScale',
                    title: i18n('taxScale'),
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(taxScaleDatas, value);
                    }
                },
                {
                    field: 'paymentMethod',
                    title: i18n('paymentMethod'),
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(paymentMethodDatas, value);
                    }
                },
                {
                    field: 'status',
                    title: i18n('status'),
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                {
                    field: 'bankOfDeposit',
                    title: i18n('bankOfDeposit')
                },
                {
                    field: 'remark',
                    title: i18n('remark')
                },
                {
                    field: 'rating',
                    title: i18n('rating')
                },
                {
                    field: 'createBy',
                    title: i18n('createBy')
                },
                {
                    field: 'createTime',
                    title: i18n('createTime')
                },
                {
                    title: i18n('operate'),
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-info btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="viewRating(\'' + row.supplierId + '\')"><i class="fa fa-edit"></i>'+i18n('viewRating')+'</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.supplierId + '\')"><i class="fa fa-edit"></i>'+i18n('edit')+'</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.supplierId + '\')"><i class="fa fa-remove"></i>'+i18n('delete')+'</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function viewRating(idVal) {
            //"供销商评分"
            $.modal.open(i18n('supplier.rating'), ctx + "supplier/rating?supplierId="+idVal);
        }
    </script>

     <script th:inline="javascript">
         //获取应用路径
         var ROOT = [[${#servletContext.contextPath}]];

         //获取默认语言
         var LANG_COUNTRY = [[${#locale.language+'_'+#locale.country}]];

         //初始化i18n插件
         $.i18n.properties({
             path: ROOT + '/i18n/',//这里表示访问路径
             name: 'messages',//文件名开头
             language: LANG_COUNTRY,//文件名语言 例如en_US
             mode: 'map'//默认值
         });

         //初始化i18n函数
         function i18n(msgKey) {
             try {
                 return $.i18n.prop(msgKey);
             } catch (e) {
                 return msgKey;
             }
         }

         //获取国际化翻译值
         //console.log(i18n('supplier.name'));
     </script>
</body>
</html>